// DHT11Sensor.cpp
#include "DHT11Sensor.h"

DHT11Sensor::DHT11Sensor(uint8_t pin) : _pin(pin), dht(pin, DHT11) {}

void DHT11Sensor::begin() {
    dht.begin();
    Serial.println("[DHT11] 初始化完成");
}

void DHT11Sensor::readData() {
    float newTemp = dht.readTemperature();
    float newHumid = dht.readHumidity();
    
    if (!isnan(newTemp) && !isnan(newHumid)) {
        temp = newTemp;
        humid = (int)newHumid;
    } else {
        Serial.println("[DHT11] 读取失败!");
    }
}
